<template>
  <section class="component case-overview">
    <common-title title="案件概况" :showIcon="false"></common-title>
    <div class="row">
      <div v-for="(item,index) of dataList" :key="index" class="col-span info">
        <div class="title">{{item.name}}</div>
        <div class="row between-span" :class="item.color">
          <svg-icon iconName="shujutongji" iconSize="48"></svg-icon>
          <div class="number">{{item.value}}</div>
        </div>
      </div>
    </div>

  </section>
</template>

<script lang="ts">
import Vue from "vue";
import Component from "vue-class-component";
import { Dependencies } from "~/core/decorator";
import SvgIcon from "~/components/common/svg-icon.vue";
import { HomePageService } from '~/services/domain-service/home-page.service';
import CommonTitle from "~/components/common/common-title.vue";

@Component({
  components: {
    SvgIcon,
    CommonTitle
  }
})
export default class CaseOverview extends Vue {
  @Dependencies(HomePageService)
  private homePageService: HomePageService

  private data = {
    newlyCaseCount: {
      name: "今日新增案件数量",
      color: "light-green",
      value: 0
    },
    waitCaseCount: {
      name: "待催收案件数量",
      color: "light-purple",
      value: 0
    },
    outFlowCaseCount: {
      name: "今日流出案件数量",
      color: "light-blue",
      value: 0
    }
  }

  private get dataList() {
    return Object.values(this.data)
  }

  private updateData() {
    // 今日新增案件数量
    this.homePageService.getNewlyCaseCount().subscribe(
      data => this.data.newlyCaseCount.value = data
    )
    // 待催收案件数量
    this.homePageService.getWaitCollectCaseCount().subscribe(
      data => this.data.waitCaseCount.value = data
    )
    // 今日流出案件数量
    this.homePageService.getOutFlowCaseCount().subscribe(
      data => this.data.outFlowCaseCount.value = data
    )
  }

  private mounted() {
    this.updateData()
  }
}
</script>

<style lang="less" scoped>
.component.case-overview {
  .info {
    margin: 5px;
    box-shadow: 0 0 3px 3px #f2f2f2;
    &:hover {
      box-shadow: 0 0 3px 3px #c5c3c3;
    }
    .title {
      font-size: 13px;
    }
    .number {
      font-weight: bold;
      margin: auto;
      margin-right: 10px;
      padding: 5px 15px;
      border-radius: 12px;
    }
  }

  .light-green {
    color: #6bbd6f;
    .number {
      background-color: #e8f5e9;
    }
  }
  .light-purple {
    color: #9674ce;
    .number {
      background-color: #ffebee;
    }
  }
  .light-blue {
    color: #18b0f4;
    .number {
      background-color: #e7f7ff;
    }
  }
}
</style>
